-- Server Side -- 

/*

-- Creates Log Database
if sql.TableExists("apple_tdm_logs") then
	else
		if (!sql.TableExists("apple_tdm_logs")) then
			local Query = "CREATE TABLE apple_tdm_logs ( ID int, Name varchar(255), ChangeValue1 text )"
			local Result = sql.Query(Query)
			if (sql.TableExists("apple_tdm_logs")) then
				MsgN("[TDM-Logs] Successfully Created Database 'apple_tdm_logs'!")
			else
				MsgN("[TDM-Logs] Database 'apple_tdm_logs' Was Not Created!")
				MsgN( sql.LastError( Result ) )
			end	
		end
MsgN("[TDM-Logs] Database 'apple_tdm_logs' Already Exists!")
local LastLogIDCreated = tonumber(sql.QueryValue( "SELECT ID FROM apple_tdm_logs ORDER BY ID DESC LIMIT 1" ))
if LastLogIDCreated == nil then
	LastLogIDCreated = 0
end
local LastLogIDCreated = (LastLogIDCreated + 1)
sql.Query( "INSERT INTO apple_tdm_logs (`ID`, `Name`, `ChangeValue1`) VALUES ('"..tonumber(LastLogIDCreated).."', 'Server', 'GameMode Has Started' ")
end


-- Sends Logs to Client
function SendLogs2Client(ply)
local CreateLogsInfoAll = sql.Query( "SELECT * FROM apple_tdm_logs" )
	if CreateLogsInfoAll == nil then 
	MsgN("NILLLLLLLLL?")
	return end -- Just in case something goes wrong
	AddLogs = {} -- The Table
	for k, v in pairs( CreateLogsInfoAll ) do
		AddLogs[k] = { -- This is the table that is added so it will transfer this to client side
		Logsid = tonumber(v['ID']),
		Logsname = tostring(v['ID']),
		Logschangevalue = tostring(v['ChangeValue1']),
		}
		
		PrintTable(AddLogs)
		
		for k, v in pairs(player.GetAll()) do
			for k,v in pairs(AddLogs) do
				umsg.Start("apple_tdm_logs")
					umsg.Short(k.Logsid)
					umsg.String(v.Logsname)
					umsg.String(v.Logschangevalue)
				umsg.End()
			end
		end
	end
end
hook.Add( "PlayerInitialSpawn", "SendLogs2Client", SendLogs2Client )

*/